use std::mem::MaybeUninit;
use sqlx::SqlitePool;
use crate::{config::SQLITE_DATA_PATH, error::SqlxErr};


static mut POOL: MaybeUninit<SqlitePool> = MaybeUninit::uninit();

pub async fn init() -> Result<(), SqlxErr> {

    let pool = SqlitePool::connect(SQLITE_DATA_PATH).await?;
    unsafe {
        POOL.write(pool);
    }

    Ok(())
}

#[inline(always)]
pub fn get_pool() -> &'static SqlitePool {
    unsafe { POOL.assume_init_ref() }
}



